
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
    {% load static %}
    <script src="{% static 'home/jquery-2.2.4.min.js' %}"></script>
</head>
<body>
<form action="{% url 'shangpinadmin:add_goods' %}" method="post">
    {% csrf_token %}
    <select name="big_class">
        {% for i in class_big %}
            {% if forloop.first %}
            <option >--------</option>
            {% endif %}
            <option name="{{ i.id }}">{{ i.name }}</option>
        {% endfor %}
    </select>

    <select name="big_class"><option >--------------</option></select>
    <select name="big_class"><option >--------------</option></select>
    <select name="big_class"><option >--------------</option></select>
    <br />
    商品名字：<input type="text" name="info"> <br />
    哪个季节的服装：
    <select name="info">
        <option >春季</option>
        <option >夏季</option>
        <option >秋季</option>
        <option >冬季</option>
    </select> <br />
    <input type="submit" value="提交">
</form>

<script type="text/javascript">
    $('select').change(function () {
        var inde = $(this).index();
        if (inde > 4) {
            '';
        }
        else if (inde == 4){
            alert('去上架商品信息吧');
        }else{
            var a = $(this).children('option:selected');
            var canshu = a.attr("name");
            var aa = $('select').eq(inde);

            $.ajax({
                url:"/shangpinadmin/class_api",
                type:"GET",
                data:{
                    "class_id":canshu,
                    "csrfmiddlewaretoken":$('[name = "csrfmiddlewaretoken]').val()
                },
                success:function (data) {
                    var name_ar = data['msg']['name'];
                    var pk = data['msg']['pk'];
                    aa.find('option').remove();
                    aa.append("<option>--------------</option>");
                    for(var L1=0;L1<name_ar.length;L1++){
                        aa.append("<option name="+pk[L1]+">"+name_ar[L1]+"</option>");
                    }

                }
            })
        }

    });
</script>






</body>
</html>